<?php
/**
 * $Id: common_controller.php 208 2009-06-23 14:09:12Z varun  $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 208 $
 * @lastModifiedBy		$LastChangedBy: varun  $
 * @lastChanged			$Date: 2009-06-23 19:39:12 +0530 (Tue, 23 Jun 2009) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

/**
 * A place for common reusable functions of CMS.
 *
 */
class CommonController extends CmsAppController
{
	var $name = 'Common';
	var $uses = array();
	
	/**
	 * Fetch cities for autocompletion widget
	 *
	 */
	function fetchCities()
	{
		Configure::write('debug', 0);
		
		$queryStr = $this->params['url']['q'];
		
		App::import('Model','Cms.City');
		
		$cityModel = new City();
		$cities = $cityModel->recommend($queryStr, 15);
			if(!empty($cities)) 
		{
			foreach($cities as $city) 
			{
				$fieldTitle = $city['City']['city'];
				echo $fieldTitle.'|'.$city['City']['id']."^";
			}
		}
		else 
		{
			echo 'No results';
		}
		exit;
	}

}

?>